<template>
	<view class="wrap">
		<ErrDialog v-if="errDialogOpen" ref="errDialog" :dialogData="dialogData" @retryFunciton="retryFunciton">
		</ErrDialog>
		<!-- <PdaScan></PdaScan> -->
		<!-- :is-scroll="true" -->
		<!-- <u-tabs :list="list" :current="current" @change="change"></u-tabs> -->
		<!-- 当前套餐 -->
		<view v-if="current === 0" style="padding-bottom: 140rpx;">
			<view class="example-body">
				<u-form-item label="作业场景" label-width="190">
					<uni-data-select @showSelector="showSelector($event)" placeholder="请选择线作业场景" clear
						v-model="form.code" :localdata="codeList" @change="changeCode"></uni-data-select>
				</u-form-item>
				<u-form-item label="线边仓工作站" label-width="190">
					<uni-data-select @showSelector="showSelector($event)" placeholder="请选择线边仓工作台" clear
						:disabled="notChangeLine" v-model="form.lineGztId" :localdata="lineGztList"
						@change="changeLineGztId"></uni-data-select>
				</u-form-item>
				<view v-show="showHeight" style="margin: 460rpx;"></view>
			</view>
			<!-- <scroll-view
			  scroll-y="true"
			  :refresher-threshold="100"
			  @refresherrefresh="refresherrefreshFun"
			  > -->
				<u-empty v-if="!hzList.length" text="无明细数据,请尝试不同的搜索条件进行搜索" mode="page"></u-empty>
				<u-radio-group v-model="groupIndex" @change="radioGroupChange">
					<u-card v-for="(item, index) in hzList" class="task-list-item" :border="false" padding="20"
						margin="20rpx" @click="selectChange(index)">

						<view slot="head" style="display: flex;align-items: center;justify-content: space-between;">
							<view style="display: flex;align-items: center;font-size: 30rpx;">
								<u-radio @change="radioChange" :name="index" :disabled="item.disabled">
									{{index+1}}:{{item.BILLNO}}
								</u-radio>
							</view>
							<view style="color: #999999;font-size: 22rpx;">{{item.BATCHNO}}</view>
						</view>
						<view class="" slot="body">
							<u-row gutter="16">
								<u-col span="12">
									<view class="apply-text"><span>名称：</span>{{item.GDCNAME}}</view>
								</u-col>
								<u-col span="12">
									<view class="apply-text"><span>数量：</span>{{item.AMOUNT}}</view>
								</u-col>
								<u-col span="12">
									<view class="apply-text"><span>时间：</span>{{item.CRTTIME}}</view>
								</u-col>
							</u-row>
						</view>
					</u-card>
				</u-radio-group>
				<u-loadmore :status="status" />
			<!-- </scroll-view> -->


			<u-row gutter="32" class="more-bottom-box" justify="center">
				<u-col span="10">
					<view>
						<view style="width: 154rpx;display: inline-block;margin-top:-10rpx;color: #999999;">
							{{needEmptyVolumeBoolean?'需要':'不需要'}}空卷
						</view>
						<u-switch style="margin-top: 30rpx;" v-model="needEmptyVolumeBoolean"
							:active-value="activeValue" :inactive-value="inactiveValue"></u-switch>
					</view>
				</u-col>
				<!-- <u-col span="10">
					<view>
						<u-button class="more-button" type="primary" shape="circle" @click="searchHz">搜索</u-button>
					</view>
				</u-col> -->

				<u-col span="10">
					<view><u-button :disabled="!hzList.length" type="primary" class="more-button" shape="circle"
							@click="issuedBefore()">下发</u-button>
					</view>
				</u-col>

			</u-row>
		</view>

	</view>
</template>
<script>
	import ErrDialog from '@/components/err-dialog.vue'
	export default {
		components: {
			ErrDialog
		},

		data() {
			return {
				outType: 'BILLTYPE_XBC',
				notChangeQuyNo: true,
				form: {
					kuf_no: '',
					quy_no: '',
					gztid: '',
					tpNum: '1',
					//1：空托入库2：空托出库
					czlx: '1',
					landpoint: 'DHJ01',
					tpbar: '',
					// 线边仓编号
					lineGztId: '',
					// 作业类型
					code: '',
				},
				showHeight: false,
				// 不允许选择线边仓工作站
				notChangeLine: true,
				errDialogOpen: false,
				// 提示信息
				dialogData: {
					title: '出库',
					msgType: '',
					errContent: '',
					confirmText: '',
					functionName: '',
					cancelText: '',
					closeFunction: '',
				},
				// 下发是否通过
				isPass: '',

				//是否为正常物料
				ISZCGD: 'N',
				keywords: '',
				form: {
					huoz_id: '',
					tpbar: '',
					itm: '',
					rwid: '',
				},
				border: true,
				show: false,
				//库房展示
				kufShow: false,

				// 工作台下拉展示
				gzzShow: false,
				// 当前工作台中文
				gztNowLabel: '',
				GZTID: '',

				// 被选中的商品明细下标
				selectItemIndex: '',
				// 托盘的商品明细
				// huojGoodsList: [],
				// 货架上的货位商品明细
				huojGoodsList: [],
				//选中的明细
				SEQNO: '',
				// 选中的货架号
				HUOJNO: '',
				//选中的货架面
				ORIENTATIONS: '',
				//当前选中的托盘号
				tpbar: '',
				kuf: '',
				// 商品相关条件
				goods: '',
				//库房
				kufList: [],
				//区域
				quNoList: [],
				//库别
				kubList: [],
				//工作台
				gztList: [],
				// 线边仓工作台
				lineGztList: [],

				// 作业场景
				codeList: [],
				//日历选择显示
				calendaShow: false,
				//有效期日历显示
				calendaEffdateShow: false,
				list: [{
					name: '明细筛选'
				}, {
					name: '明细总览',
				}],

				m2mSimflowList: [],
				m2mOrderFlowList: [],
				current: 0,
				result1: '',
				status: 'nomore',
				iconType: 'circle',
				isDot: false,
				loadText: {
					loadmore: '点击加载更多',
					loading: '正在加载...',
					nomore: '没有更多了'
				},
				// 搜索栏的托盘号
				tpbar: '',
				nvueWidth: 730,
				only_one: [{
					text: '选择此项',
					value: 0
				}],
				// 基础表单数据
				baseFormData: {
					name: '',
					age: '',
					introduction: '',
					sex: 2,
					hobby: [5],
					datetimesingle: 1627529992399
				},
				// 汇总信息存储
				hzData: {

				},
				// 点击的汇总下标
				hzIndex: '',
				refreshInHead: true,
				refreshMxMsg: true,
				hzList: [

				],
				needEmptyVolume: 1,
				needEmptyVolumeBoolean: true,
				activeValue: 1,
				inactiveValue: 0,
				//物料是否是新批次
				newItemid: false,
				// 直接缓存明细吧，
				oldMx: '',
				// 选中的明细行编号/单号等
				groupIndex: '',
				// 配合下拉框高度，显示完全的高度
				topHeight: 0,
				oneMx: {},
				disableTrue: true,
				// 入库点
				landpoint: '',
				sjAmouont: '1',
				sjLocation: '',
			}
		},
		// 该写提交盘点单了 接口7

		onLoad(option) {
			this.form.code = uni.getStorageSync("line-side-warehouse-code")

			// this.form.kuf_no = uni.getStorageSync("line-side-warehouse-kuf_no")
			// this.getKufbyKuf()
			setTimeout(() => {
				if (this.form.code) {
					this.notChangeLine = false
					this.getLineGzt()
					this.form.lineGztId = uni.getStorageSync("line-side-warehouse-lineGztId")
					if (this.form.lineGztId) {
						this.searchHz()
					}
				}
				// this.form.quy_no = uni.getStorageSync("line-side-warehouse-quy_no")
				// this.from.quy_no ="直接是缓存中的值"
			}, 20)
			// this.form.tpNum=uni.getStorageSync("line-side-warehouse-landpoint")

			// if (option) {
			// 	if (option.item) {
			// 		let item = JSON.parse(option.item)
			// 		this.hzData = item
			// 		console.log('收到的:' + JSON.stringify(item))
			// 		console.log('收到的:' + item.INPAGENO)
			// 		this.tpbar = item.INPAGENO;
			// 		this.getInListOneInfo()
			// 	}
			// }
		},

		created() {
			this.getCodeList()
			this.getLineGzt()
			// this.getKuf(2)
			// this.getKuf(3)
			// this.getGzt()
			// this.init()
			// this.searchHz()
		},
		// 数据变化适用
		onShow() {
			this.myShow()

		},
		onBackPress() {
			console.log("点击了返回")
			uni.switchTab({
				url: "/pages/sys/workbench/wms-work"
			})
			return true
		},

		//下拉刷新触发方法(和onLoad同级)
		onPullDownRefresh () {
		    this.refresherrefreshFun()  //获取数据
			setTimeout(function () {
			            uni.stopPullDownRefresh();
			        }, 300);
		},
		methods: {
			// 下拉刷新被触发
				refresherrefreshFun() {
					console.log("下拉触发")
					this.hzList = []
					// this.params.pageNum = 1
					// this.showSelector(false)
					this.getCodeList()
					this.getLineGzt()
				},
			// 涂步机头上料第一步判断逻辑
			// 根据作业类型，进行是否需要判断 入库
			// 是否是正常物料
			isNarmalGoods() {
				// 1、IV\_STAFF 用户id
				// 2、IV\_GOODSID 商品id  上游商品id gdseq
				// 3、IV\_ITEMID 批次  传%
				// 4、IV\_BATCHNO 批号
				// 5、IV\_OUT\_LX 下发场景  TBSL(场景类型)
				// 6、IV\_CKJH  下发：1，拣货2  传1
				const index = this.groupIndex
				const item = this.hzList[index]

				const USER_ID = uni.getStorageSync('USER_ID')
				const GDSEQ = item.GDSEQ
				const ITEMID = "%"
				const BATCHNO = item.BATCHNO ? item.BATCHNO : "%"
				const OUT_LX = this.form.code ? this.form.code : "%"
				const CKJH = 1
				let param = USER_ID + "," + GDSEQ + "," + ITEMID + "," +
					BATCHNO + "," + OUT_LX + "," + CKJH;
				console.log("iv_parm:" + param)

				this.oldMx = item

				this.$u.api.general({
						iv_code: "PDAGETFIRSTOUTFLG",
						iv_parm: param
					})
					.then(res => {
						console.log("返回的res:" + JSON.stringify(res))

						if (res.success) {
							let data = res.data
							console.log("isNarmalGoods（）返回的data:" + JSON.stringify(data))
							data = data[0]
							// 是否为新批次属性赋值
							this.newItemid = data.ISFIRSTOUT
							//先判断是否是新物料
							// let ok = data.ISZCGD == 'Y' ? '是' : '不是'
							const a = data.ISZCGD == 'Y'
							console.log('是否是正常物料判断：' + a)

							if (data.ISZCGD == 'Y') {
								this.iszcgdAndIsNewItemid()
							} else {
								this.ifFirstItemidNO()
							}

						} else {
							this.dialogData = {
								title: '线边仓作业(是否是正常物料？)',
								msgType: 'warn',
								errContent: res.msg,
								confirmText: '重试',
								functionName: 'isNarmalGoods',
								cancelText: '关闭',
								closeFunction: '',
							}
							this.errDialogShow()
						}
					});
			},
			// 是正常物料  判断是否新批次，给弹框提示
			iszcgdAndIsNewItemid() {
				const a = this.newItemid == 'Y'
				console.log('（正常物料）弹窗判断是否为新批次：' + a)
				// 是新批次的话，弹框提示一下，不是新批次，就直接pass下发
				if (this.newItemid == 'Y') {
					//弹窗
					let ok = this.newItemid == 'Y' ? '是' : '不是'
					this.dialogData = {
						title: '线边仓作业(是否为新批次?)',
						msgType: 'warn',
						errContent: '系统判定：[' + this.oldMx.BATCHNO + ']' + ok + '新批次',
						confirmText: '我知道了',
						functionName: 'changeIfFirstItemidYES',
						cancelText: '关闭',
						closeFunction: 'changeIfFirstItemidYES',
					}
					this.errDialogShow()
				} else {
					this.changeIfFirstItemidYES()
				}

			},
			// 不是正常物料，判断是否是新批次，给弹框 逻辑
			ifFirstItemidNO() {

				const a = this.newItemid == 'Y'
				console.log('是否是新批次判断：' + a)
				//弹窗
				if (this.newItemid == 'Y') {
					let ok = this.newItemid == 'Y' ? '是' : '不是'
					this.dialogData = {
						title: '线边仓作业(是否同意为新批次?)',
						msgType: 'warn',
						errContent: '系统判定：[' + this.oldMx.BATCHNO + ']' + ok + '新批次',
						confirmText: '是（生成下发单）',
						functionName: 'changeIfFirstItemidYES',
						cancelText: '否(关闭上料单)',
						closeFunction: 'changeIfFirstItemidNO',
					}
					this.errDialogShow()
					// this.changeIfFirstItemidYES()
				} else {
					//是正常物料，不是新批次，直接pass下发
					this.changeIfFirstItemidYES()
				}
			},
			// 选择了不下发任务，关闭上料单   用户拒绝了系统判定的是新批号
			changeIfFirstItemidNO() {
				console.log('选择了不下发任务，关闭上料单')
				this.isPass = 'N'
				this.issued()
			},
			// pass下发
			changeIfFirstItemidYES() {
				console.log('pass下发')
				this.isPass = 'Y'
				this.issued()
			},
			// 是正常物料；是否为新批次
			ifFirstItemidYES() {
				const a = this.newItemid == 'Y'
				console.log('弹窗判断是否为新批次：' + a)
				if (this.newItemid == 'Y') {
					//弹窗
					let ok = this.newItemid == 'Y' ? '是' : '不是'
					this.dialogData = {
						title: '线边仓作业(是否为新批次?)',
						msgType: 'warn',
						errContent: '系统判定：[' + this.oldMx.BATCHNO + ']' + ok + '新批次',
						confirmText: '是',
						functionName: 'changeIfFirstItemidYES',
						cancelText: '否',
						closeFunction: 'changeIfFirstItemidNO',
					}
					this.errDialogShow()
				} else {
					this.changeIfFirstItemidYES()
				}
			},


			// 选中某个单选框时，由radio时触发
			radioChange(e) {
				console.log('由radio时触发' + e);
				this.selectItemIndex = e
			},
			// 方便操作
			selectChange(e) {
				console.log('点击卡片触发' + e);
				// 商品数据
				this.selectItemIndex = e
				this.oneMx = this.hzList[e]
				// 选中样式值绑定
				this.groupIndex = e
			},
			//view

			//methods
			// 动态设置占位区高度
			setHeight() {
				this.$nextTick(() => {
					uni.createSelectorQuery().select('.top-box').boundingClientRect().exec((res) => {
						//异步方法，无法return出去，也无法将变量传至外部，故另起一个全局变量
						this.topHeight = res[0].height
					})
				})
				return `height:${this.topHeight}px`
			},

			// 选中任一radio时，由radio-group触发
			radioGroupChange(e) {
				console.log("SEQNO:" + this.groupIndex)
				console.log("radioGroupChange:" + e);
				this.oneMx = this.hzList[e]
				console.log("单选选择的明细:" + JSON.stringify(this.oneMx))
			},
			navTo(url) {
				// uni.navigateTo({
				// 	url: url
				// });
				// uni.switchTab({
				// 	url: url
				// });
				uni.switchTab({
					url: url,
					success: function(e) {
						var page = getCurrentPages().pop(); // 返回页面数组的最后一个页面数据
						if (page == undefined || page == null)
							return; //如果最后一个页面为undefined或null，即当前就在首页 return出去，不调用onLoad
						page.onLoad();
					}
				});


			},
			searchHz() {
				// this.getInListOneInfo()
				// this.getOutTpbarList()
				// this.getCheckList()
				this.getLineSideList()

			},
			overStyle(over) {
				if (over) {
					return "text-align: right;color: #58ca93;";
				} else {
					return "text-align: right;color: #f28c03;";
				}
			},
			init() {
				this.GZTID = uni.getStorageSync('IN_GZTID')
				this.kuf = uni.getStorageSync('kuf')
			},
			issuedBefore() {
				//根据作业场景，会有不同的判断逻辑和弹框
				let code = this.form.code
				console.log('作业场景code：' + code)
				switch (code) {
					// 涂布机头上料
					case 'TBSL':
						this.isNarmalGoods();
						break;
						//涂布机头下料
					case 'TBXL':
						this.changeIfFirstItemidYES();
						break;
						// 辊分机头上料
					case 'GFJT':
						this.isNarmalGoods();
						break;
						//辊分机尾下料
					case 'GFXL':
						this.gfjtIssued();
						break;
						//模切机上料
					case 'MQSL':
						this.isNarmalGoods();
						break;
						//模切机下料
					case 'MQXL':
						this.mqslIssued();
						break;
						//卷绕机上料
					case 'JRSL':
						this.isNarmalGoods();
						break;
					default:
						console.log('没有作业场景！')
						this.$u.toast('没有对应的作业场景处理，直接进行下发')
						this.isPass='Y'
						this.issued();
						break;
				}
			},
			gfjtIssued() {
				this.$u.toast('(辊分机尾下料)暂无处理逻辑')
				this.isNarmalGoods()
			},
			mqslIssued() {
				this.$u.toast('(模切机下料)暂无处理逻辑')
				this.isNarmalGoods()
			},
			issued() {
				// 1、IV\_STAFF 作业人员
				// 2、IV\_OUTTYPE 单据类型
				// 3、IV\_BILLNO 单号
				// 4、IN\_ITM 行号
				// 5、IV\_ISKJ 是否空卷
				// 6、IV\_ISPASS 是否通过

				console.log("oneMx=>" + JSON.stringify(this.oneMx))

				const USER_ID = uni.getStorageSync('USER_ID')
				const OUTTYPE = this.form.code ? this.form.code  : '%'
				const BILLNO = this.oneMx.BILLNO ? this.oneMx.BILLNO : "%"
				const ITM = this.oneMx.ITM ? this.oneMx.ITM : "%"

				const ISKJ = this.needEmptyVolumeBoolean ? 'Y' : 'N'
				const ISPASS = this.isPass ? this.isPass : '%'


				let param = USER_ID + "," +
					OUTTYPE + "," +
					BILLNO + "," +
					ITM + "," +
					ISKJ + "," +
					ISPASS;

				console.log("iv_parm:" + param + ";")
				let that = this
				this.$u.api.prcutlexecvar({
						iv_code: "XBCGZTBILLXF",
						iv_parm: param,
						ov_var1: '2',
						ov_var2: '2',
						ov_var3: '2',
						ov_var4: '2',
						ov_var5: '2',
					})
					.then(res => {
						console.log("返回的res:" + JSON.stringify(res))

						if (res.success) {
							that.$u.toast(res.msg);
							let data = res.data
							// console.log("返回的data:" + JSON.stringify(data))
							console.log("返回的res.msg:" + res.msg)
							this.submitSuccess()
							// if (paramReturn == "returnSearch") {
							// 	this.current = 0
							// }
						} else {
							this.dialogData = {
								title: '线边仓任务下发',
								msgType: 'error',
								errContent: res.msg,
								confirmText: '重新下发',
								// 如果选右边的执行的返回方法
								functionName: 'issued',
								cancelText: '关闭',


								closeFunction: '',
							}
							this.errDialogShow()
						}
						// 清空pass逻辑
						this.isPass = ''

					});

			},

			submitQuertion() {
				this.dialogData = {
					title: '单据下发',
					msgType: 'warn',
					errContent: 准备线边仓单据下发,
					confirmText: '下发',
					// 如果选右边的执行的返回方法
					functionName: 'submitCheck',
					cancelText: '关闭',
					closeFunction: '',
				}
				this.errDialogShow()
			},

			// 是否新批次出库第一托?
			isFirshOut() {
				// 1、IV\_STAFF 用户id
				// 2、IV\_GOODSID 商品id
				// 3、IV\_ITEMID 批次
				// 4、IV\_BATCHNO 批号
				// 5、IV\_OUT\_LX 出库场景类型
				// 6、IV\_CKJH 出库下发：1，拣货2
				const USER_ID = uni.getStorageSync('USER_ID')

				const GOODSID = this.oneMx.GOODSID ? this.oneMx.GOODSID : "%"
				const ITEMID = this.oneMx.ITEMID ? this.oneMx.ITEMID : "%"
				const BATCHNO = this.oneMx.BATCHNO ? this.oneMx.BATCHNO : "%"
				const OUT_LX = this.oneMx.OUTTYPE ? this.oneMx.OUTTYPE : "%"
				const CKJH = 2
				let param = USER_ID + "," + GOODSID + "," + ITEMID + "," +
					BATCHNO + "," + OUT_LX + "," + CKJH;
				console.log("iv_parm:" + param)
				this.$u.api.general({
						iv_code: "PDAGETFIRSTOUTFLG",
						iv_parm: param
					})
					.then(res => {
						 console.log("返回的res:" + JSON.stringify(res))
						if (res.success) {
							let data = res.data
							console.log("返回的data:" + JSON.stringify(data))
							// this.hzData = data[0]
							// if (this.list.length < 1) {
							// 	this.$u.toast("没有查到数据");
							// }

							// 如果是第一次出库,进行提示
							if (data.ISFIRSTOUT == 'Y') {
								this.dialogData = {
									title: '出库检测(第一托?)',
									msgType: 'warn',
									errContent: '本明细是新批次出库第一托',
									confirmText: '继续进行出库(判断是否为正常物料)',
									// 如果选右边的执行的返回方法
									functionName: 'isNarmalGoods',
									cancelText: '关闭',
								}
								this.errDialogShow()
								this.ISZCGD = data.ISZCGD
								// if(data.ISZCGD=='Y'){
								// 	this.ISZCGD = 'Y'
								// }
							} else {
								this.submitOut()
							}

						} else {
							this.$u.toast(res.msg);
						}
					});
			},
			retryFunciton(e) {
				console.log("子组件返回的e:" + e)
				if (e == "isNarmalGoods") {
					this.isNarmalGoods()
				} else if (e == "submitCheck") {
					this.submitCheck()
				} else if (e == 'changeIfFirstItemidNO') {
					this.changeIfFirstItemidNO()
				} else if (e == 'changeIfFirstItemidYES') {
					this.changeIfFirstItemidYES()
				}else if(e == 'getLineSideList'){
					this.getLineSideList()
				}
			},
			// 是否是
			// isNarmalGoods() {
			// 	if (this.ISZCGD == 'Y') {
			// 		// (对应PDA弹窗提醒)
			// 		this.dialogData = {
			// 			title: '出库检测(正常物料?)',
			// 			msgType: 'warn',
			// 			errContent: '本明细是正常物料',
			// 			confirmText: '我知道了',
			// 			// 如果选右边的执行的返回方法
			// 			functionName: 'submitOut',
			// 			cancelText: '关闭',
			// 		}
			// 		this.errDialogShow()
			// 	} else if (this.ISZCGD == 'N') {
			// 		// 对应pda弹窗选择确认
			// 		this.dialogData = {
			// 			title: '出库检测(正常物料?)',
			// 			msgType: 'error',
			// 			errContent: '本明细不是正常物料',
			// 			confirmText: '同意此物料不是正常物料',
			// 			// 如果选右边的执行的返回方法
			// 			functionName: 'submitOut',
			// 			cancelText: '拒绝',
			// 			closeFunction: 'noNormalGoods',

			// 		}
			// 		this.errDialogShow()
			// 	} else {
			// 		this.$u.toast('ISZCGD未知,严重错误,请排查isFirshOut()返回值')
			// 	}
			// },
			noNormalGoods() {
				this.$u.toast('点击了否,不同意')
			},
			// // 是正常物料的弹窗提示(权限控制,指定账号弹窗)
			// isToast(){

			// },
			errDialogShow() {
				console.log("刷新显示提示框")
				//刷新显示
				let that = this;
				that.errDialogOpen = false;
				that.$nextTick(() => {
					that.errDialogOpen = true;
				})

			},

			//重新加载子组件
			myShow() {

				console.log("this.hzData==>" + JSON.stringify(this.hzData))
				//刷新显示
				let that = this;
				that.refreshInHead = false;
				that.$nextTick(() => {
					that.refreshInHead = true;
				})

			},
			myMxShow() {
				//刷新显示
				let that = this;
				that.refreshMxMsg = false;
				that.$nextTick(() => {
					that.refreshMxMsg = true;
				})

			},

			scan1(param) {
				console.log("扫描")
				// #ifdef H5
				this.$u.toast('H5页面不支持扫码,请用安卓等移动设备重试')
				// #endif
				let that = this;
				// 允许从相机和相册扫码
				uni.scanCode({
					success: function(res) {
						if (param == "tpbar") {
							that.tpbar = res.result;
						} else if (param == "LOCATIONZD") {
							that.sjLocation = res.result
						}

					}
				});
			},
			change(index) {
				console.log(this.current)
				this.current = index;
			},
			submit(index) {
				if (this.tpbar) {
					this.$u.toast('调用下架接口')
				} else {
					this.$u.toast('请补充入库单号的数据')
				}
			},
			submitCheck(paramReturn) {


				// 1、IV\_STAFF 人员
				// 2、IV\_PDNO 盘点单号
				// 3、IN\_SORTSN 行号
				// 4、IV\_JS 件数
				// 5、IV\_LSS 零散数
				// 6、IN\_AMOUNT 实盘数量

				// console.log("oneMx=>" + JSON.stringify(this.oneMx))
				// const USER_ID = uni.getStorageSync('USER_ID')
				// const PDNO = this.oneMx.PDNO ? this.oneMx.PDNO : "%"
				// const SORTSN = this.oneMx.SORTSN ? this.oneMx.SORTSN : "%"
				// const JS = 0
				// const LSS = this.oneMx.AMOUNT ? this.oneMx.AMOUNT : "0"
				// const AMOUNT = this.oneMx.AMOUNT ? this.oneMx.AMOUNT : "0"


				// let param = USER_ID + "," +
				// 	PDNO + "," +
				// 	SORTSN + "," +
				// 	JS + "," +
				// 	LSS + "," +
				// 	AMOUNT;

				// console.log("iv_parm:" + param + ";")
				// let that = this
				// this.$u.api.prcutlexecvar({
				// 		iv_code: "PDRWQR",
				// 		iv_parm: param,
				// 		ov_var1: '2',
				// 		ov_var2: '2',
				// 		ov_var3: '2',
				// 		ov_var4: '2',
				// 		ov_var5: '2',
				// 	})
				// 	.then(res => {
				// 		console.log("返回的res:" + JSON.stringify(res))
				// 		if (res.success) {
				// 			that.$u.toast(res.msg);
				// 			let data = res.data
				// 			// console.log("返回的data:" + JSON.stringify(data))
				// 			console.log("返回的res.msg:" + res.msg)
				// 			this.submitSuccess()
				// 			if (paramReturn == "returnSearch") {
				// 				this.current = 0
				// 			}
				// 		} else {
				// 			this.dialogData = {
				// 				title: '盘点提交',
				// 				msgType: 'error',
				// 				errContent: res.msg,
				// 				confirmText: '重新提交',
				// 				// 如果选右边的执行的返回方法
				// 				functionName: 'submitCheck',
				// 				cancelText: '关闭',
				// 				closeFunction: '',
				// 			}
				// 			this.errDialogShow()
				// 		}

				// 	});
			},
			submitOutBefore() {
				//是否新批次出库第一托
				this.isFirshOut()
			},

			// 提交成功后，刷新汇总集合，如果包含locationid 老的，
			// 那说明这个盘点单还没做完，直接获取明细，
			// 如果不包含，那么提示已经做完，并且跳转到汇总选择页面，供用户选择
			submitSuccess() {
				this.hzList = []
				this.searchHz()
				// if(!huojGoodsList.length){
				// 	console.log("已经做完")

				// 	//回到明细列表
				// 	this.change(0)
				// 	this.$u.toast("盘点单："+this.hzData.PDNO+"已完结")
				// }
				// console.log("提交成功，执行查找this.huojGoodsList.length:" + this.huojGoodsList.length)
				// 如果剩余一个了，并且成功了，那么是不是就可以转到汇总数据列表了

				// if (this.huojGoodsList.length < 2) {
				// 	this.$u.toast("该货位所有商品已盘点完毕")
				// 	this.current = 0
				// 	this.hzData = ''
				// 	this.searchHz()
				// } else {
				// 	this.$u.toast("还有" + Number(this.huojGoodsList.length - 1) + "个商品需要盘点")
				// 	this.searchHz()
				// 	this.huojGoodsList = ''
				// 	this.getLocationMxList(this.hzData)
				// }

				// const oldLocationid = this.hzData.LOCATIONID
				// console.log("oldLocationid:"+oldLocationid)
				// console.log("this.hzList:"+JSON.stringify(this.hzList))
				// const newHzList = this.hzList.filter((item) => {
				// 	return item.LOCATIONID === oldLocationid
				// })
				// debugger
				// if (newHzList) {
				// 	console.log("该盘点单还没做完")
				// 	// 先清空，再覆盖
				// this.huojGoodsList = ''
				// this.getLocationMxList(this.hzData)
				// 	return;
				// } else{
				// 	this.current = 0
				// 	this.hzData=[]
				// 	this.hzIndex=''
				// }


			},
			navTo(url) {
				uni.navigateTo({
					url: url
				});
			},
			// 根据货位进行搜索
			getLocationMxList(item) {

				// 1、IV\_STAFF 人员
				// 2、IV_LOCATIONID 货位
				const USER_ID = uni.getStorageSync('USER_ID')
				const locationid = item.LOCATIONID

				let param = USER_ID + "," + locationid;

				console.log("iv_parm:" + param)
				let that = this
				this.$u.api.general({
						iv_code: "GETPDHWDETAILDISP",
						iv_parm: param
					})
					.then(res => {
						 console.log("返回的res:" + JSON.stringify(res))
						if (res.success) {
							let data = res.data
							console.log("返回的data:" + JSON.stringify(data))
							//补充text
							this.huojGoodsList = data
							this.oneMx = this.huojGoodsList[0]

							this.status = 'nomore';
						} else {
							this.$u.toast(res.msg);
						}
					});
			},
			// 获取线边仓工作站任务列表
			getLineSideList() {

				const user_id = uni.getStorageSync("USER_ID")
				const lineGztId = this.form.lineGztId ? this.form.lineGztId : '%'
				let param = user_id + "," + lineGztId
				console.log("iv_parm:" + param)
				let that = this
				this.$u.api.general({
						iv_code: "GETXBCGZTBILL",
						iv_parm: param
					})
					.then(res => {
						// console.log("返回的res:" + JSON.stringify(res))

						if (res.success) {
							let data = res.data
							console.log("线边仓工作站任务列表返回的data:" + JSON.stringify(data))
							//补充text
							this.hzList = data
							if (this.hzList.length < 1) {
								this.$u.toast("暂无数据");
							}
							this.status = 'nomore';
							// 默认选择第一个
							this.oneMx = this.hzList[0]
							this.groupIndex = 0

						} else {

							this.dialogData = {
								title: '查询错误',
								msgType: 'error',
								errContent: res.msg,
								confirmText: '重新提交',
								// 如果选右边的执行的返回方法
								functionName: 'getLineSideList',
								cancelText: '关闭',
								closeFunction: '',
							}
							this.errDialogShow()
						}
					});
			},
			// 获取盘点任务列表
			getCheckList() {
				// 1、IV\_STAFF 人员
				// 2、IV\_GZTID 工作台
				// 3、IV\_STORAGEID 仓库
				// 4、IV\_KUF\_NO 库房
				// 5、IV\_QUY\_NO 区域
				const USER_ID = uni.getStorageSync('USER_ID')
				const GZTID = this.GZTID ? this.GZTID : "%"
				const STORAGE_ID = uni.getStorageSync('STORAGE_ID')
				const kuf_no = this.form.kuf_no ? this.form.kuf_no : '%'
				const quyu_no = this.form.quyu_no ? this.form.quyu_no : '%'
				let param = USER_ID + "," + GZTID + "," + STORAGE_ID +
					"," + kuf_no + "," + quyu_no;
				console.log("iv_parm:" + param)
				let that = this
				this.$u.api.general({
						iv_code: "GETPDHWDISP",
						iv_parm: param
					})
					.then(res => {
						 console.log("返回的res:" + JSON.stringify(res))
						if (res.success) {
							let data = res.data
							console.log("返回的data:" + JSON.stringify(data))
							//补充text
							this.hzList = data
							if (this.hzList.length < 1) {
								this.$u.toast("暂无数据");
							}
							this.status = 'nomore';


						} else {
							this.$u.toast(res.msg);
						}
					});
			},
			getOutTpbarList() {
				// 1、IV\_STAFF 用户id
				// 2、IV\_GZTID 工作站
				// 3、IV\_YEW\_TYPE业务类型2：出库
				// const STORAGE_ID = uni.getStorageSync('STORAGE_ID')
				// // const USER_GH = uni.getStorageSync('USER_GH')
				// const yez_id = this.form.huoz_id ? this.form.huoz_id : "%"
				const USER_ID = uni.getStorageSync('USER_ID')
				const GZTID = this.GZTID ? this.GZTID : "%"
				const yew_type = '2'
				let param = USER_ID + "," + GZTID + "," + yew_type;
				console.log("iv_parm:" + param)
				let that = this
				this.$u.api.general({
						iv_code: "PDAOUTTPBAR",
						iv_parm: param
					})
					.then(res => {
						// console.log("返回的res:" + JSON.stringify(res))
						let data = res.data
						// console.log("返回的data:" + JSON.stringify(data))
						if (res.success) {
							//补充text
							this.hzList = data

							this.status = 'nomore';


						} else {
							this.$u.toast(res.msg);
						}
					});
			},

			blurFunction() {
				console.log("失去了焦点")
				this.myMxShow()
			},
			changeProductDate(e) {
				console.log("选择的日期:" + JSON.stringify(e))
				this.oneMx.PRODUCTDATE = e.result
				this.myMxShow()
			},
			changeEFFDATE(e) {
				this.oneMx.EFFDATE = e.result
				this.myMxShow()
			},
			changeGzt(index) {
				// 表层文字
				this.gztNowLabel = this.gztList[index].text;
				uni.setStorageSync('gztNowLabel', this.gztNowLabel)

				// id
				const GZTID = this.gztList[index].GZTID == "%" ? '' : this.gztList[index].GZTID;
				if (GZTID) {
					this.GZTID = GZTID
					uni.setStorageSync('IN_GZTID', GZTID)

				} else {
					this.GZTID = ''
					uni.removeStorageSync('IN_GZTID')
				}
				console.log("缓存中的入库工作站IN_GZTID:" + uni.getStorageSync('IN_GZTID'))

			},

			changeQuyNo(e) {
				this.form.quy_no = e
				uni.setStorageSync("line-side-warehouse-quy_no", e)
				console.log("盘点缓存区域号:" + uni.getStorageSync("line-side-warehouse-quy_no"))
			},
			changeLineGztId(e) {
				this.form.lineGztId = e
				uni.setStorageSync("line-side-warehouse-lineGztId", e)
				console.log("线边仓作业工作站编号:" + uni.getStorageSync("line-side-warehouse-lineGztId"))
				this.showSelector(false)
				this.searchHz()
			},
			// 下拉内容是否展开
			showSelector(res) {
				console.log(res)
				this.showHeight = res
			},
			changeCode(e) {
				this.form.code = e
				uni.setStorageSync("line-side-warehouse-code", e)
				console.log("线边仓作业缓存作业场景:" + uni.getStorageSync("line-side-warehouse-code"))
				// 选择后，可以选择线边仓工作站
				this.notChangeLine = false
				this.getLineGzt()
				this.showSelector(false)
				this.searchHz()
			},
			changeKuf(e) {
				console.log("e:" + e);
				console.log("this.kufList:" + JSON.stringify(this.kufList))
				// const item = this.kufList[e];
				// console.log("item:"+item)
				this.form.kuf_no = e
				console.log(this.form.kuf_no)
				// 判断一下区域是不是在这个库房,如果在,就不更改区域,如果不在,就更改区域
				this.getKufbyKuf()
				this.notChangeQuyNo = e ? false : true

				uni.setStorageSync("line-side-warehouse-kuf_no", e)
				console.log("盘点缓存库房号:" + uni.getStorageSync("line-side-warehouse-kuf_no"))

			},
			// 查看选择到的库房的区域
			getKufbyKuf() {
				const USER_ID = uni.getStorageSync('USER_ID')
				const KUB = '%'
				const KUF_NO = this.form.kuf_no ? this.form.kuf_no : "%"
				//1获取库别，2获取库房，3获取区域
				const GET_TYPE = 3
				let param = USER_ID + "," + KUB + "," + KUF_NO + "," + GET_TYPE;
				console.log(param)
				this.$u.api.general({
						iv_code: "GETKUFQUYNO",
						iv_parm: param
					})
					.then(res => {
						console.log("getKufbyKuf返回的res:" + JSON.stringify(res))
						let data = res.data
						console.log("查看选择到的库房的区域返回的data:" + JSON.stringify(data))
						if (res.success) {

							this.form.quy_no = uni.getStorageSync("line-side-warehouse-quy_no")
							console.log("this.form.quy_no:" + this.form.quy_no)
							let newData = [];
							if (this.form.quy_no) {
								//补充text
								newData = data.filter((item) => {
									// 过滤如果有对象的区域参数和已经够选择的区域no相同,那么就不用覆盖已经选择的
									return item.QUY_NO === this.form.quy_no
								})
							}

							if (newData.length > 0) {
								console.log("不用重新选择,这是从对象集合种筛出来的区域号相同的对象=>" + JSON.stringify(newData))
								this.quNoList = data.map(v => {
									this.$set(v, 'text', v.QUY_NO)
									this.$set(v, 'value', v.QUY_NO)
									return v
								})
							} else {
								console.log("重新选择,这是库房对应的对象集合,=>" + JSON.stringify(data))
								this.quNoList = data.map(v => {
									this.$set(v, 'text', v.QUY_NO)
									this.$set(v, 'value', v.QUY_NO)
									return v
								})
								//如果切换的区域
								this.form.quy_no = ''
							}
							this.canChangeQuy_no()
						} else {
							this.errContent = res.msg
							this.$u.toast(res.msg);
						}
					});
			},
			// 将区域可选
			canChangeQuy_no() {
				this.notChangeQuyNo = false
			},
			getGzt(loginType) {
				const user_id = uni.getStorageSync('USER_ID')
				const STORAGE_ID = uni.getStorageSync('STORAGE_ID')
				const kuf = "%"
				const gztType = "1"
				const gztId = "%"
				let param = user_id + "," + STORAGE_ID + "," + kuf + "," + gztType + "," + gztId;
				console.log(param)
				this.$u.api.general({
						iv_code: "GETGZTINFO",
						iv_parm: param
					})
					.then(res => {
						// console.log("返回的res:" + JSON.stringify(res))
						let data = res.data
						console.log("getGzt返回的data:" + JSON.stringify(data))
						if (res.success) {
							//补充text
							this.gztList = data.map(v => {
								this.$set(v, 'text', v
									.GZTNAME + "(" + v.GZTID + ")"
								) // https://vuejs.org/v2/guide/reactivity.html
								return v
							})

							// 增加一条特殊的测试数据
							this.gztList.push({
								"text": "DHJ01",
								"WORKLOAD": "4",
								"CENG": "1",
								"GZT_TYPE": "1",
								"ISZCQFP": "N",
								"STORAGEID": "SU3",
								"WORKSTATION_TYPE": "0",
								"LETDOWNFLAG": "1",
								"GZTID": "DHJ01",
								"GZTNAME": "DHJ01测试工作站",
								"KUF_NO": "LHK"
							})
						} else {
							this.$u.toast(res.msg);
						}
					});
			},
			// 获取作业场景
			getCodeList(loginType) {
				// 1、用户id,
				// 2、仓库传%，
				// 3、库房传%,
				// 4、工作站类型：1入，2出；
				// 5、工作台id传%

				// const user_id = uni.getStorageSync('USER_ID')
				// 固定写死
				// const STORAGE_ID = 'TBSL'
				// const kuf = "%"
				// const gztType = "1"
				// const gztId = "%"
				// 线边仓编码code
				const billtype_xbc = this.outType
				let param = billtype_xbc
				console.log(param)
				this.$u.api.general({
						iv_code: "GETCODEMX",
						iv_parm: param
					})
					.then(res => {
						// console.log("返回的res:" + JSON.stringify(res))
						let data = res.data
						console.log("code返回的data:" + JSON.stringify(data))
						if (res.success) {
							//补充text
							this.codeList = data.map(v => {
								this.$set(
									v, 'text', v.CODE_VALUE_NAME + "(" + v.CODE_VALUE + ")"
								)
								this.$set(
									v, 'value', v.CODE_VALUE
								)
								return v
							})

							// // 增加一条特殊的测试数据
							// this.gztList.push({
							// 	"text": "DHJ01",
							// 	"WORKLOAD": "4",
							// 	"CENG": "1",
							// 	"GZT_TYPE": "1",
							// 	"ISZCQFP": "N",
							// 	"STORAGEID": "SU3",
							// 	"WORKSTATION_TYPE": "0",
							// 	"LETDOWNFLAG": "1",
							// 	"GZTID": "DHJ01",
							// 	"GZTNAME": "DHJ01测试工作站",
							// 	"KUF_NO": "LHK"
							// })
						} else {
							this.$u.toast(res.msg);
						}
					});
			},
			// 获取线边仓工作站
			getLineGzt(loginType) {
				const user_id = uni.getStorageSync('USER_ID')
				// 固定写死
				const STORAGE_ID = this.form.code
				// const kuf = "%"
				// const gztType = "1"
				// const gztId = "%"
				let param = user_id + "," + STORAGE_ID
				console.log(param)
				this.$u.api.general({
						iv_code: "GETXBCGZT",
						iv_parm: param
					})
					.then(res => {
						// console.log("返回的res:" + JSON.stringify(res))
						let data = res.data
						console.log("getGzt返回的data:" + JSON.stringify(data))
						if (res.success) {
							//补充text
							this.lineGztList = data.map(v => {
								this.$set(
									v, 'text', v.GZTNAME + "(" + v.GZTID + ")"
								)
								this.$set(
									v, 'value', v.GZTID
								)
								return v
							})
							if(this.lineGztList.length>0){
								this.form.lineGztId  = this.lineGztList[0].value
							}

							// // 增加一条特殊的测试数据
							// this.gztList.push({
							// 	"text": "DHJ01",
							// 	"WORKLOAD": "4",
							// 	"CENG": "1",
							// 	"GZT_TYPE": "1",
							// 	"ISZCQFP": "N",
							// 	"STORAGEID": "SU3",
							// 	"WORKSTATION_TYPE": "0",
							// 	"LETDOWNFLAG": "1",
							// 	"GZTID": "DHJ01",
							// 	"GZTNAME": "DHJ01测试工作站",
							// 	"KUF_NO": "LHK"
							// })
						} else {
							this.$u.toast(res.msg);
						}
					});
			},


		}

	}
</script>
<style lang="scss" scoped>
	@import '../../common/index.scss';
	@import '../../common/base-change.scss';
</style>
